package test;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;

import java.util.Properties;

/**
 * 测试
 *  发送日志数据到kafka的ods层中
 */
public class KafkaOdsData {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "node01:9092");

        KafkaProducer<String, String> producer = new KafkaProducer<>(props,new StringSerializer(),new StringSerializer());
        for (int i = 0; i < 20; i++) {
            producer.send(new ProducerRecord<>("ods_logs","2001:980:91c0:1:8d31:a232:25e5:85d 123.235.228.56 - [05/Sep/2010:11:27:50 +0200] \"GET /images/my.jpg HTTP/1.1\" 404 23617 \"http://www.angularjs.cn/A00n\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; nl-nl) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8\""));
        }

        producer.close();
    }
}
